package com.xjh;

import cn.hutool.core.util.IdUtil;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.xjh.t.common.Constast;
import com.xjh.t.domain.User;
import com.xjh.t.service.IUserService;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.junit.Test;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
@EnableScheduling
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@MapperScan(basePackages = {"com.xjh.t.mapper"})
//@ServletComponentScan(basePackages = {"com.xjh.t.filter"})
public class ApplicationWeb {

    @Autowired
    IUserService userService;
    public static void main(String[] args) {

        SpringApplication.run(ApplicationWeb.class, args);

    }




    @Test
    public void testMonth()
    {

        User user=new User();
        user.setId(1);
        String salt= IdUtil.simpleUUID().toUpperCase();
        user.setSalt(salt);//设置盐
        user.setPwd(new Md5Hash(Constast.USER_DEFAULT_PWD, salt, 2).toString());//设置密码

       // IUserService userService =
       // this.userService.updateById(user);

        /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        //Date date = sdf.parse("2019-02-02");
        Calendar c = Calendar.getInstance();
        //设置为指定日期
        c.setTime(new Date());
        //指定日期月份减去一
        c.add(Calendar.MONTH, -2);
        //指定日期月份减去一后的 最大天数
        c.set(Calendar.DATE, c.getActualMaximum(Calendar.DATE));
        //获取最终的时间
        Date lastDateOfPrevMonth = c.getTime();
        System.out.println("上月最后一天：" + sdf.format(lastDateOfPrevMonth));


        c.setTime(new Date());
        c.set(Calendar.DAY_OF_MONTH,1);
        c.add(Calendar.MONTH,-2);

        lastDateOfPrevMonth = c.getTime();
        System.out.println("上月第一天：" + sdf.format(lastDateOfPrevMonth));*/

    }
}
